package com.example.administrator.jingpingou.bean;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 小吧 on 2016/9/1.
 */
public class Shop_Two {

    /**
     * data : [{"num_iid":"27538684339","title":"紫砂香盘 盘香炉熏香炉 香粉炉 香插盘香座","now_price":"","origin_price":12,"discount":0,"pic_url":"http://g.search2.alicdn.com/img/i2/1809450347/TB2yd68XVXXXXXfXXXXXXXXXXXX_!!1809450347.jpg_220x220.jpg"},{"num_iid":"38050417380","title":"透气男鞋2014网鞋休闲","now_price":"69.00","origin_price":690,"discount":1,"pic_url":"http://g.search3.alicdn.com/img/i3/727813890/T2HWf.XKpXXXXXXXXX_!!727813890.jpg_220x220.jpg"}]
     * info : success
     */

    private String info;
    /**
     * num_iid : 27538684339
     * title : 紫砂香盘 盘香炉熏香炉 香粉炉 香插盘香座
     * now_price :
     * origin_price : 12
     * discount : 0
     * pic_url : http://g.search2.alicdn.com/img/i2/1809450347/TB2yd68XVXXXXXfXXXXXXXXXXXX_!!1809450347.jpg_220x220.jpg
     */

    private List<DataYan> data;

    public static Shop_Two objectFromData(String str) {

        return new Gson().fromJson(str, Shop_Two.class);
    }

    public static Shop_Two objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), Shop_Two.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<Shop_Two> arrayShop_TwoFromData(String str) {

        Type listType = new TypeToken<ArrayList<Shop_Two>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<Shop_Two> arrayShop_TwoFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<Shop_Two>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public List<DataYan> getData() {
        return data;
    }

    public void setData(List<DataYan> data) {
        this.data = data;
    }

    public static class DataYan {
        private String num_iid;
        private String title;
        private String now_price;
        private int origin_price;
        private int discount;
        private String pic_url;

        public static DataYan objectFromData(String str) {

            return new Gson().fromJson(str, DataYan.class);
        }

        public static DataYan objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), DataYan.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<DataYan> arrayDataYanFromData(String str) {

            Type listType = new TypeToken<ArrayList<DataYan>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<DataYan> arrayDataYanFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<DataYan>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public String getNum_iid() {
            return num_iid;
        }

        public void setNum_iid(String num_iid) {
            this.num_iid = num_iid;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getNow_price() {
            return now_price;
        }

        public void setNow_price(String now_price) {
            this.now_price = now_price;
        }

        public int getOrigin_price() {
            return origin_price;
        }

        public void setOrigin_price(int origin_price) {
            this.origin_price = origin_price;
        }

        public int getDiscount() {
            return discount;
        }

        public void setDiscount(int discount) {
            this.discount = discount;
        }

        public String getPic_url() {
            return pic_url;
        }

        public void setPic_url(String pic_url) {
            this.pic_url = pic_url;
        }
    }
}
